[FLINK-39197][jdbc&mysql] Fix NPE when finding chunk end#4296
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes FLINK-39197 by preventing a NullPointerException during snapshot chunk splitting when the computed next chunk end is null (e.g., rows containing max values are removed between min/max discovery and subsequent chunk boundary queries).
Changes:
- Add an early
nullreturn inMySqlChunkSplitter.nextChunkEnd(...)whenqueryNextChunkMax(...)returnsnull. - Add the same early
nullreturn in the baseJdbcSourceChunkSplitter.nextChunkEnd(...)to protect all JDBC-based connectors.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/main/java/org/apache/flink/cdc/connectors/mysql/source/assigners/MySqlChunkSplitter.java | Prevents NPE in MySQL snapshot chunk splitting when the next chunk end cannot be determined (returns null). |
| flink-cdc-connect/flink-cdc-source-connectors/flink-cdc-base/src/main/java/org/apache/flink/cdc/connectors/base/source/assigner/splitter/JdbcSourceChunkSplitter.java | Applies the same null-guard to the shared JDBC chunk splitting logic used by multiple connectors. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
I think this change is reasonable, and I'm +1 on the code modifications to ChunkSplitter. However, your test doesn't demonstrate that this change is risk-free. It would be more reliable to add a test with an actual reader that performs chunk splitting and data reading to verify that no errors occur and the data is correct. |
Co-authored-by: Chengbing Liu <liuchengbing@qiyi.com>
Fix https://issues.apache.org/jira/browse/FLINK-39197
We encountered the following problem when using MySQL pipeline connector:
This should be because max values are removed resulting in chunkEnd == null, as mentioned in